package com.kaka.bus.engine.amount.creditamount;

import com.kaka.bus.bean.HttpWrapper;
import com.kaka.bus.bean.ProductDetailBean;
import com.kaka.bus.bean.Status;
import com.kaka.bus.constant.Constant;
import com.kaka.bus.di.DataManager;
import com.kaka.bus.engine.common.impl.LoanService;
import com.kaka.bus.manager.Result;
import com.kaka.bus.manager.T;
import com.kaka.bus.mvp.RxPresenter;

import java.util.List;

import javax.inject.Inject;

public class ManageamountPresenter extends RxPresenter<ManageamountContract.View> implements ManageamountContract.Presenter {
    LoanService mLoanService;

    @Inject
    public ManageamountPresenter(DataManager dataManager, LoanService loanService) {
        super(dataManager);
        mLoanService = loanService;
        setService(loanService);
    }


    @Override
    public void loadProduct(String per_id, String token, String device, int productId, String version) {
        addSubscribe(mDataManager.getApi()
                .getLoanProduct(per_id, token, Constant.PLATFORM, productId, version)
                .compose(T.D()).subscribeWith(new Result<HttpWrapper<List<ProductDetailBean>>>() {

                    @Override
                    protected void onSuccess(HttpWrapper<List<ProductDetailBean>> listHttpWrapper) {
                        mView.getLoadProduct(listHttpWrapper);
                    }
                }));
    }

    @Override
    public void getLimit(String userId, String token) {
//        mLoanService.getBpmList(userId, token, new Result<HttpWrapper<List<BpmList>>>() {
//            @Override
//            protected void onSuccess(HttpWrapper<List<BpmList>> listHttpWrapper) {
//                mView.getLimitSuccess(listHttpWrapper);
//            }
//        });
    }

    @Override
    public void checkBpm(String userId, String token) {
        mLoanService.checkBpm(userId, token, new Result<HttpWrapper<Status>>() {
            @Override
            protected void onSuccess(HttpWrapper<Status> wrapper) {
                mView.checkBpmSuccess(wrapper);
            }
        });
    }
}
